package org.dtrd.modules.patient.entity.bean;

import com.fasterxml.jackson.annotation.JsonFormat;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Getter;
import lombok.Setter;
import org.dtrd.config.system.Constant;
import org.dtrd.modules.achievement.entity.bean.PatientSigninStatusBean;
import org.dtrd.modules.flup.entity.bean.FlupRecord;
import org.dtrd.modules.record.entity.bean.DailySigninDietStatus;
import org.dtrd.modules.record.entity.bean.PatientDailySugar;
import org.dtrd.modules.record.entity.bean.ValueUplowBean;
import org.dtrd.modules.service.entity.bean.PatientServiceIndexInfo;

import java.util.Date;
import java.util.List;

/**
 * @author qr
 * @date 2022/1/12 13:58
 */
@ApiModel("患者首页统计数据")
@Setter
@Getter
public class PatientHomePageInfo {

    @ApiModelProperty("患者信息完成百分比")
    private Integer infoCompletePercentage = 0;

    @ApiModelProperty("分组名称")
    private String groupName;

    @ApiModelProperty("服务状态, 0-没有服务，1-服务中，2-待服务，3-已结束")
    private Integer serviceStatus = 0;
    @ApiModelProperty("服务名称")
    private String serviceName;
    @ApiModelProperty("服务开始时间")
    @JsonFormat(timezone = "GMT+8", pattern = Constant.TIME_PATTERN_SDF)
    private Date serviceStartTime;
    @ApiModelProperty("服务结束时间")
    @JsonFormat(timezone = "GMT+8", pattern = Constant.TIME_PATTERN_SDF)
    private Date serviceEndTime;

    @ApiModelProperty(value = "复诊状态", notes = "复诊状态, 0-未预约, 1-待复诊, 2-已复诊, 3-未复诊, 4-复诊中, 5-已预约")
    private Integer flupStatusNum;
    @ApiModelProperty("复诊状态文本")
    private String flupStatus;
    @ApiModelProperty("复诊时间")
    @JsonFormat(timezone = "GMT+8", pattern = Constant.TIME_PATTERN_SDF)
    private Date flupDate;

    @ApiModelProperty("本月消费")
    private Double consumptionThisMonth = 2000.34;
    @ApiModelProperty("全部消费")
    private Double consumptionTotal = 50000.5;


    @ApiModelProperty("打卡状态, 0-未开始, 1-使用中, 2-已结束, 3-暂停中, 4-没有打卡计划")
    private Integer signinStatus;
    @ApiModelProperty("打卡次数")
    private Integer signinCount = 0;
    @ApiModelProperty("打卡天数")
    private Integer signinDay = 0;
    @ApiModelProperty("漏打卡次数")
    private Integer noSigninCount = 0;
    @ApiModelProperty("打卡分数")
    private Integer signinScore = 0;

    @ApiModelProperty("早餐打卡状态")
    private boolean breakfast;
    @ApiModelProperty("午餐打卡状态")
    private boolean lunch;
    @ApiModelProperty("午餐打卡状态")
    private boolean dinner;

    @ApiModelProperty("今日血糖列表")
    private List<Float> sugarValues;
    @ApiModelProperty("血糖时间列表")
    private List<String> sugarTimes;

    @ApiModelProperty("标签列表")
    private List<String> tags;

    @ApiModelProperty("上下限信息")
    private ValueUplowBean uplowInfo;

    public void parseFromDTO(PatientServiceIndexInfo serviceIndexInfo) {
        serviceName = serviceIndexInfo.getServiceName();
        serviceEndTime = serviceIndexInfo.getServiceEndTime();
        serviceStartTime = serviceIndexInfo.getServiceStartTime();
        serviceStatus = serviceIndexInfo.getServiceStatus();
    }

    public void parseFromDTO(PatientDailySugar dto) {
        sugarValues = dto.getSugarValues();
        sugarTimes = dto.getSugarTimes();
    }

    public void parseFromDTO(FlupRecord flupRecord) {
        this.flupStatusNum = flupRecord.getFlupStatus();
        this.flupStatus = flupRecord.getFlupStatusText();
        Constant.FlupStatus status = Constant.FlupStatus.valueOf(flupRecord.getFlupStatus());
        switch (status) {
            case WaitToVisit:
            case HasAppointment:
            case NotVisited:
                this.setFlupDate(flupRecord.getFlupDate());
                break;
            case Visiting:
                this.setFlupDate(flupRecord.getFlupRealStartTime());
                break;
            case HadVisited:
                this.setFlupDate(flupRecord.getFlupRealEndTime());
                break;
            default:
                break;
        }
    }

    public void parseFromDTO(PatientSigninStatusBean patientSigninStatusBean) {
        this.signinCount = patientSigninStatusBean.getSigninCount();
        this.signinDay = patientSigninStatusBean.getSigninDay();
        this.noSigninCount = patientSigninStatusBean.getNoSigninCount();
        this.signinStatus = patientSigninStatusBean.getSigninStatus();
    }

    public void parseFromDTO(DailySigninDietStatus signinDietStatus) {
        this.dinner = signinDietStatus.isDinner();
        this.lunch = signinDietStatus.isLunch();
        this.breakfast = signinDietStatus.isBreakfast();
    }
}
